using System;
using System.Collections;
using System.Collections.Generic;
namespace Circus.CodeEditor.TextSource
{
	public class UndoList : List<UndoData>, IList<UndoData>, ICollection<UndoData>, IEnumerable<UndoData>, IEnumerable
	{
		private int updateCount;
		private int undoCount;
		public virtual int UpdateCount
		{
			get
			{
				return this.updateCount;
			}
		}
		public int UndoCount
		{
			get
			{
				return this.undoCount;
			}
		}
		public virtual int BeginUpdate()
		{
			this.updateCount++;
			return this.updateCount;
		}
		public virtual int EndUpdate()
		{
			this.updateCount--;
			if (this.updateCount == 0)
			{
				this.Update();
			}
			return this.updateCount;
		}
		public virtual int DisableUpdate()
		{
			this.updateCount++;
			return this.updateCount;
		}
		public virtual int EnableUpdate()
		{
			this.updateCount--;
			return this.updateCount;
		}
		public void Update()
		{
			this.undoCount = 0;
			foreach (UndoData current in this)
			{
				if (current.Operation != UndoOperation.Navigate || current.Data != null)
				{
					this.undoCount++;
				}
			}
		}
		public new void Clear()
		{
			base.Clear();
			this.undoCount = 0;
		}
		public new void Add(UndoData item)
		{
			base.Add(item);
			if (item.Operation != UndoOperation.Navigate || item.Data != null)
			{
				this.undoCount++;
			}
		}
		public new void RemoveAt(int index)
		{
			UndoData undoData = base[index];
			if (undoData.Operation != UndoOperation.Navigate || undoData.Data != null)
			{
				this.undoCount--;
			}
			base.RemoveAt(index);
		}
	}
}
